<%@page pageEncoding="UTF-8"  contentType="application/json; charset=UTF-8"  %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@taglib uri="http://chances.com.cn/jsp/epgdata" prefix="epgdata"%>
<%@taglib uri="http://chances.com.cn/jsp/schedule" prefix="schedule"%>
<%@taglib  uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<epgdata:categoryItem var="menu_cat" size="4" code="${_templateParams['menu_cat']}" />
<epgdata:bizList var="chnMenu" code="${_templateParams['channelMenu_biz']}"/>
<c:set var="tab" value="<%=\"\t\" %>" />

{
	"status": "200",
	"title": "_context.biz.title",
	"code": "${_context.bizCode}",
	"areaDatas": 
	[
		
		{
			"areaCode":"${_templateParams['menu_cat']}",
			"areaType": "",
			"areaTitle": "导航",
			"items":[
				<c:forEach var="item" items="${menu_cat}" varStatus="idx">
					{
					"itemTitle": "${item.title}",
					"itemCode": "${item.itemCode}",
					"itemType": "${item.itemType}",
					"itemIcon": "${item.itemIcon}",
					"dataLink": "${item.url}"
					}<c:if test="${!idx.last }">,</c:if>
				</c:forEach>
			]
		},
		
		{
			"areaCode":"${_templateParams['channelMenu_biz']}",
			"areaType": "",
			"areaTitle": "频道导航",
			"items":[
				<c:forEach var="item" items="${chnMenu}" varStatus="indx">
					{
					"itemTitle": "${item.title}",
					"itemCode": "${item.code}",
					"dataLink": "${item.url}",
					"items":[
						<epgdata:categoryItem var="items" size="999" code="${item.categoryCode}" />
						<c:forEach var="item" items="${items}" varStatus="idx">
							<schedule:playing var="schedule" size="1" channelCode="${item.itemCode}"/>
							<fmt:formatDate var="startTime" value="${schedule[0].startTime}" pattern="HH:mm"/>
							<schedule:playNext var="next" size="1" channelCode="${item.itemCode}"/>
							<fmt:formatDate var="startTimeNext" value="${next[0].startTime}" pattern="HH:mm"/>
							{
								"itemTitle": "${item.title}",
								"itemCode": "${item.itemCode}",
								"itemType": "${item.itemType}",
								"itemIcon": "${_resourcePath}${item.itemIcon}",
								"dataLink": "${item.url}",
								"current": {
									"startTime":"${startTime}",
									"name":"${fn:replace(schedule[0].name, tab, ' ')}"
								},
								"next": {
									"startTime":"${startTimeNext}",
									"name":"${fn:replace(next[0].name, tab, ' ')}"
								}
							}<c:if test="${!idx.last }">,</c:if>
						</c:forEach>
					]
					}<c:if test="${!indx.last }">,</c:if>
				</c:forEach>
			]
		}
	]
}
